import Vue from 'vue'
import Router from 'vue-router'
import CateList from "../views/user/CateList";
import Home from "../components/Home";
import UserList from "../views/user/UserList";
import AddUser from "../views/user/AddUser";
import Login from "../components/Login";


Vue.use(Router)

export default new Router({
  mode:'history',
  routes: [
    {
      path: '/CateList',
      name: 'CateList',
      component: CateList
    },
    {
      path: '/',
      name: 'Home',
      component: Home,
      // beforeEbter(to,from,next){
      //   // 路由守卫 判断是否登录
      //   let token = localStorage.getItem('token')
      //   if (token){
      //     next() // 放行
      //   }else {
      //     alert('请先登录')
      //     next('/Login')
      //   }
      // },
      children:[
        {
          path: '/UserList',
          name: 'UserList',
          component: UserList
        },
        {
          path: '/AddUser',
          name: 'AddUser',
          component: AddUser
        },
      ]
    },
    {
      path: '/Login',
      name: 'Login',
      component: Login
    },
  ]
})
